﻿@model IEnumerable<OES.Models.Exam>
@{
    ViewBag.Title = "Sınavlar";
}
<h2>
    Sınavlar</h2>
<p>
    @Html.ActionLink("Yeni sınav oluştur", "Create")
</p>

    @Html.DropDownList("CourseId")
   
<table class="table table-bordered table-striped">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.course.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Duration) 
            @Html.Raw("(dk)")
        </th>
        <th>
            @Html.DisplayNameFor(model => model.StartTime)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FinishTime)
        </th>
        <th>@Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
        </th>
        <th>
        </th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.course.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Duration)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.StartTime)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FinishTime)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.ActionLink("Güncelle", "Edit", new { id = item.ExamId }) |
                @Html.ActionLink("Detaylar", "Details", new { id = item.ExamId }) |
                @Html.ActionLink("Sil", "Delete", new { id = item.ExamId })
            </td>
            <td>
                @if (item.Questions.Count != 0)
                {
                    @Html.ActionLink("Sorular", "Soru", new { id = item.ExamId })
                    
                }
            </td>
        </tr>
    }
</table>
@section Scripts {
    <script type="text/javascript">
        $(document).ready(function () {
            $("#CourseId").change(function () {
                var dDown = document.getElementById("CourseId");
                var chosenoption = dDown.options[dDown.selectedIndex];
              
                window.location="/Exam/Index/" + chosenoption.value;



            });


        });


    </script>
}
